//
//  ViewController.m
//  07-核心动画-cabasicanimation
//
//  Created by J on 16/2/23.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *heart;

@property (weak, nonatomic) IBOutlet UIView *grayView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //创建动画
    CABasicAnimation* ani = [CABasicAnimation animation];
    
    //描述下修改哪个属性产生动画
//    ani.keyPath = @"position";
    ani.keyPath = @"transform.scale";

    //设置值
//    ani.toValue = [NSValue valueWithCGPoint:CGPointMake(250, 250)];
    ani.toValue = @0.5;
    ani.repeatCount = CGFLOAT_MAX;
    
    //取消回弹需要这两步
    //设置动画完成的时候不要移除动画
    ani.removedOnCompletion = NO;
    
    //动画执行完成要保持最新的效果
    ani.fillMode = kCAFillModeForwards;
    
    
    
    [_heart.layer addAnimation:ani forKey:nil];
    
 
    
}

@end
